package cn.com.demo.shiro.controller;

import cn.com.demo.shiro.entity.TShiroUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoController {
    @GetMapping("/")
    public String demo(){
        // 拿到当前用户
        Subject subject = SecurityUtils.getSubject();
        TShiroUser user  = (TShiroUser) subject.getPrincipal();
        return "OK:" + user.getUsername();
    }
    @GetMapping("/p1")
    public String p1(){
        return "p1 OK";
    }
    @GetMapping("/p2")
    public String p2(){
        return "p2 OK";
    }
}
